var atm = {}

atm.ajax = function(ajaxObject) {
    //requestType, requestURL, requestParam, successCallBackFunction

    $.ajax({
        type : ajaxObject.requestType || 'POST',
        dataType : 'JSON',
        url : ajaxObject.requestURL,
        data : ajaxObject.requestParam || {},
        success : function (result) {
            if (result.code != 1000){
                alert(result.message);
                if (result.code == 5555) {
                    window.location.href = '/';
                    return;
                }
                return;
            }

            //如果木有给回调函数，则不执行
            if (ajaxObject.successCallBackFunction === undefined) {
                return;
            }
            ajaxObject.successCallBackFunction(result);
        }
    });
}

atm.loadMyCard = function () {
    $.ajax({
        type : 'GET',
        dataType : 'JSON',
        url : '/card/queryMyCard.do',
        data : {
        },
        success : function (result) {
            if (result.code != 1000){
                alert(result.message);
                return;
            }

            var cards = result.data;
            var myCardHtml = '<option value="no">请选择银行卡</option>';

            for (var i=0; i<cards.length; i++) {
                var card = cards[i];
                myCardHtml += '<option value="'+card.cardId+'">'+card.cardNum+'</option>';
            }

            $('#myCardsSelect').html(myCardHtml);
        }
    });
}